﻿<Window x:Class="Conquera.BattlePrototype.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:proto="clr-namespace:Conquera.BattlePrototype"
    Title="Window1" Height="594" Width="783" WindowState="Maximized" Loaded="Window_Loaded">
    
    <Window.Resources>
        <proto:ColorToBrushConverter x:Key="ColorToBrushConverter" />
    </Window.Resources>
    
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="18" />
            <RowDefinition Height="*" />
            <RowDefinition Height="150" />
        </Grid.RowDefinitions>
        
        <!--Header-->
        <Border HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="{Binding ActivePlayer.Color, RelativeSource={RelativeSource AncestorType={x:Type Window}}, Converter={StaticResource ColorToBrushConverter}}" />        
        <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
            <TextBlock x:Name="mRedTextBlock" Background="Silver" Foreground="Red" Margin="0,0,10,0"/>
            <TextBlock x:Name="mBlueTextBlock" Background="Silver" Foreground="Blue" />
        </StackPanel>
            
        <!--Main canvas-->
        <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" Grid.Row="1">
            <Canvas x:Name="mMainCanvas" PreviewMouseMove="mMainCanvas_PreviewMouseMove" PreviewMouseDown="mMainCanvas_PreviewMouseDown" PreviewMouseUp="mMainCanvas_PreviewMouseUp">
                <Canvas.RenderTransform>
                    <ScaleTransform ScaleX="{Binding Value, ElementName=mZoomSlider}" ScaleY="{Binding Value, ElementName=mZoomSlider}" />
                </Canvas.RenderTransform>
            </Canvas>
        </ScrollViewer>
        
        <!--Splitter-->
        <GridSplitter Grid.Row="2" HorizontalAlignment="Stretch" VerticalAlignment="Top" Height="2" />

        <!--GUI-->
        <TabControl Margin="0,2,0,0" Grid.Row="2" x:Name="mTabControl" SelectionChanged="mTabControl_SelectionChanged">


            <!--Game GUI-->
            <TabItem Header="Game" x:Name="mGameTabItem">
                <StackPanel Orientation="Horizontal">
                    <Button Content="Resolve Pre-Battle" Click="Button_Click" x:Name="mEndTurnButton"/>
                    <!--<ListBox ItemsSource="{Binding ActivePlayer.CardsInHand, RelativeSource={RelativeSource AncestorType={x:Type Window}}}" />-->
                    
                    <ListBox x:Name="mCardsListBox" SelectionChanged="mCardsListBox_SelectionChanged">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding}" MouseDown="CardItem_MouseDown" ToolTip="{Binding Card.ToolTip}">
                                    <TextBlock.Background>
                                        <MultiBinding>
                                            <MultiBinding.Converter>
                                                <proto:CanCastCardConverter />
                                            </MultiBinding.Converter>
                                            <Binding Path="Card.Cost" />
                                            <Binding Path="ActivePlayer.Mana" RelativeSource="{RelativeSource AncestorType={x:Type Window}}" />
                                        </MultiBinding>
                                    </TextBlock.Background>
                                </TextBlock>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                    
                    <Button Click="mUnselectCardButton_Click" Content="Deselect Card"/>

                    <ListBox Name="mLogBox" MinWidth="50" Margin="10,0,0,0"/>
                    <Button Content="X" Click="Button_Click_1" />
                </StackPanel>
            </TabItem>
            <!--Editor GUI-->
            <TabItem Header="Editor" x:Name="mEditorTabItem">
                <StackPanel Orientation="Horizontal" >

                    <!--Players-->
                    <StackPanel Margin="2,2,2,2">
                        <TextBlock Text="Players" Foreground="White" Background="{Binding SelectedItem.Color, ElementName=mPlayersListBox, Converter={StaticResource ColorToBrushConverter}}" />

                        <ListBox x:Name="mPlayersListBox">
                            <ListBox.ItemTemplate>
                                <DataTemplate>
                                    <Border x:Name="mPlayerBorder" Width="30" Height="16" Background="{Binding Color, Converter={StaticResource ColorToBrushConverter}}" />
                                </DataTemplate>
                            </ListBox.ItemTemplate>
                        </ListBox>
                        <Button Content="None" x:Name="mSelectNonePlayerButton" Click="mSelectNonePlayerButton_Click"/>
                    </StackPanel>

                    <!--Set tile-->
                    <StackPanel Margin="2,2,2,2">
                        <RadioButton x:Name="mSetTilesOptionBox" GroupName="Editor" IsChecked="True">Tile</RadioButton>
                        <ListBox x:Name="mSetTilesListBox" SelectedIndex="0" PreviewMouseDown="mSetTilesListBox_PreviewMouseDown" SelectionChanged="mSetTilesListBox_SelectionChanged"/>
                        <TextBlock x:Name="mSetTilesLeftButtonTextBlock" />
                        <TextBlock x:Name="mSetTilesRightButtonTextBlock" />
                    </StackPanel>
                    
                    <!--Capture, StartPos-->
                    <StackPanel Margin="2,2,2,2">
                        <RadioButton x:Name="mCaptureOptionBox" GroupName="Editor">Capture</RadioButton>
                        <RadioButton x:Name="mStartPosOptionBox" GroupName="Editor">StartPos</RadioButton>
                    </StackPanel>
                    
                    <!--Save/load map-->
                    <StackPanel Margin="2,2,2,2" Orientation="Horizontal">
                        <ListBox x:Name="mMapsListBox" MouseDoubleClick="mMapsListBox_MouseDoubleClick" />
                        <StackPanel Width="108" Margin="2,0,2,0">
                            <TextBox x:Name="mSaveMapTextBox" />
                            <Button Content="SaveMap" Click="button1_Click" />                        
                        </StackPanel>
                    </StackPanel>
                    
                    <!--Reset map-->
                    <Button Content="Reset" Click="mResetButton_Click" />
                </StackPanel>
            </TabItem>




        </TabControl>        
        
        <StackPanel Orientation="Horizontal" Grid.Row="2" HorizontalAlignment="Right" VerticalAlignment="Top">
            <Slider Grid.Row="2" Height="20" HorizontalAlignment="Right" Margin="0,0,0,0" Name="mAiMapInfoAlphaSlider" VerticalAlignment="Top" Width="114" Minimum="0" Maximum="255" Value="200" ValueChanged="mAiMapInfoAlphaSlider_ValueChanged" />
            <ComboBox Grid.Row="2" Height="23" Width="200" Margin="0,0,0,0" Name="mAiMapInfoComboBox" VerticalAlignment="Bottom" SelectionChanged="mAiMapInfoComboBox_SelectionChanged" HorizontalAlignment="Left" />
            <Slider Grid.Row="2" Height="22" HorizontalAlignment="Right" Margin="0,1,0,0" Name="mZoomSlider" VerticalAlignment="Top" Width="261" Minimum="0.3" Maximum="1" Value="1"/>        
        </StackPanel>
    </Grid>
</Window>
